<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/base.css" />
<link rel="stylesheet" href="css/util.css" />
<link rel="stylesheet" href="css/collect.css" />
<title>业务员列表</title>
</head>
<body>
<div class="content employee">
	<div class="navigate_head clearfix">
		<p onclick="window.location.href='salesman_list.html'" class="navi_current">业务员信息</p>
		<p onclick="window.location.href='add_salesman.html'">添加业务员</p>
		<p class="navi_null"></p>
	</div>
	<table>
		<thead>
			<tr>
				<!--<td>序号</td>-->
				<td>姓名</td>
				<td>手机号</td>
				<td>状态</td>
				<td>操作</td>
			</tr>
		</thead>
		<tbody class="tbody">
			<!--<tr>
				<td>1</td>
				<td>张三</td>
				<td>165 1238 6549</td>
				<td>状态</td>
				<td><button class="font_green">修改</button>&nbsp;&nbsp;<button class="font_green">删除</button></td>
			</tr>-->
		</tbody>
	</table>
	<!--分页-->
	<div class="page flex_vertical">
		<button class="" onclick="indexPage()">首页</button>&nbsp;
		<button class="" onclick="backPage()"><上一页</button>&nbsp;
		<!--页码-->
		<p class="page_num">
			<!--<span>1</span><span>2</span><span>3</span><span>4</span><span>5</span>-->
		</p>....
		<button class="" onclick="nextPage()">下一页></button>&nbsp;
		<button class="" onclick="endPage()">末页</button>&nbsp;
		共<span class="all_recode">0 </span>记录&nbsp;|
		共<span class="all_page">0 </span>页&nbsp;
		到第<input class="select_page" />页&nbsp;
		<button class="confirm_page" onclick="skipPage()">确定</button>
	</div>
</div>
<script type="text/javascript" src="plug/jquery-1.11.3.js" ></script>
<script type="text/javascript" src="plug/template-web.js"></script>
<script type="text/javascript" src="js/toggle.js" ></script>
<script type="text/javascript" src="js/util.js"></script>
<script type="text/javascript" src="js/method.js"></script>
<script type="text/javascript" src="js/page.js"></script>
<!--业务员列表-->
<script id="test_salesman_list" type="text/html">
{{each data value}}
	<tr>
		<!--<td>1</td>-->
		<td>{{value.name}}</td>
		<td>{{value.mobile}}</td>
		<td>
			{{if value.enabled==true}}启用{{else if value.enabled==false}}关闭{{/if}}
		</td>
		<td data_id="{{value.id}}">
			<button class="font_green" onclick="edit_salesman(this)">修改</button>
			<!--&nbsp;<button class="font_green" onclick="del_tyq(this)">删除</button>-->  
		</td>
	</tr>
{{/each}}
</script>

<script>
//请求方法
function reqPage(data){
	console.log(data);
	control_page.init_page(data,function(data){
		//调用ajax
		$.get_ajax("/admin/salesman/getList.json",data,function(data){
			console.log(data);
			var html = template('test_salesman_list',data);
			$(".tbody").html(html);
			//初始化分页
			control_page.currentPage(control_page.page_num,data.totalCount);
		});
	});
}

//修改业务员
function edit_salesman(m){
	var salesman_id = $(m).parent().attr("data_id");
	window.localStorage.setItem("salesman_id",salesman_id);
	window.location.href = "edit_salesman.html";
}
//删除体验券
function del_tyq(m){
	var tyq_id = $(m).parent().attr("data_id");
	var data = {
		"id":tyq_id
	}
	$.post_ajax("/admin/experienceReservation/delete",data,function(data){
		if(data.success==true){
			alert(data.data);
			window.location.href = "tyq_list.html"
		}else{
			alert(data.data);
		}
	});
}

</script>
<script>
$(function(){
	reqPage(control_page.getData());
});
</script>
</body>
</html>
